<template>
  <div class="post-container">
    <div class="post-main">
      <div class="origin-section">
        <div class="avatar">
          <img :src="post.avatar" alt="avatar" />
        </div>
        <div class="info">
          <div class="nickname">{{ post.nickname }}</div>
          <div class="content">{{ post.content }}</div>
          <ImageGallery class="pictures" :srcs="post.pictures.map(p => p.url)" type="show"></ImageGallery>
          <div class="bottom">
            <div class="time">发表于 {{ post.postTime }}</div>
            <div class="status">
              <span class="forward">{{ post.forwardNum }}转发</span>
              <span class="like">{{ post.likeNum }}点赞</span>
              <span class="comment">{{ post.commentNum }}评论</span>
            </div>
          </div>
        </div>
      </div>
      <div class="comment-section">
        <div class="title">全部评论</div>
        <div class="comment-list">
          <Comment
            v-for="item in post.comments"
            :key="item.id"
            :comment="item"
          ></Comment>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Comment from "_c/Comment";
import ImageGallery from './ImageGallery.vue';
export default {
  name: "Post",
  components: { Comment, ImageGallery },
  props: ["post"],
};
</script>

<style scoped lang="scss">
.comment-container {
  padding: 10px;
}
.origin-section {
  display: flex;
}
.avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin-right: 20px;
  border-radius: 50%;
  img {
    object-fit: cover;
    width: 100%;
    height: 100%;
    border-radius: 50%;
  }
}
.info {
  > div {
    margin-bottom: 10px;
  }

  .pictures {
    .img-box {
      width: 100px;
      height: 100px;
    }
  }
  .bottom {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
  }
  .time {
    color: #afafaf;
  }
  .status {
    > span {
      margin-right: 10px;
    }
  }
}
.comment-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
  .title {
    margin-bottom: 10px;
  }
}
</style>
